﻿Option Strict Off

Imports DBUtilitiesLibrary
Imports DARSClassLibrary
Public Class AddAppointment
    Inherits System.Web.UI.Page

    Dim objdb As New DARSDBConnection
    Dim sql As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("CurrentUser") Is Nothing Then
            Response.Redirect("NotLoggedIn.aspx")
            Exit Sub
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
        lblSuccess.Text = ""
        Dim dt As DateTime = calDateSelect.SelectedDate
        Dim newDate As String = calDateSelect.SelectedDate.ToShortDateString
        Dim newTime As String = ddlHour.SelectedValue & ":" & ddlMinute.SelectedValue & ":00 " & ddlAMPM.SelectedValue
        Dim newDateTimeStr As String = newDate & " " & newTime
        dt = DateTime.Parse(newDateTimeStr)
        Dim ws As New DO_NOT_MOVE_ME_FROM_THIS_PROJECT.DARSWebservice
        sql = "Insert Into Appointment (AdvisorID, DateTime) Values ('" & CType(Session("CurrentUser"), Advisor).AdvisorID & "', '" & dt.ToString & "')"
        Dim x As Integer = objdb.doUpdate(sql)
        If x > 0 Then
            lblSuccess.Text = "Appointment Added Successfully!"
        Else
            lblSuccess.Text = "Appointment Was Not Added"
        End If
    End Sub

    Protected Sub logout(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogout.ServerClick
        Session.Abandon()
        Response.Redirect("NotLoggedIn.aspx")
    End Sub

    Protected Sub home(ByVal sender As Object, ByVal e As EventArgs) Handles btnhome.ServerClick
        Response.Redirect("AdvisorLandingPage.aspx")
    End Sub

End Class